#pragma once
#include "HashTable.hpp"

namespace zh
{
	template<class K, class V, class Hash = OPEN_HASH::_Hash<K>>
	class unordered_map
	{
	private:
		struct MapKOfT
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};

		OPEN_HASH::HashTable<K, pair<K, V>, MapKOfT,Hash> _ht;
	public:
		typedef typename OPEN_HASH::__HashTableIterator<K, pair<K, V>, MapKOfT, Hash> iterator;

		iterator begin()
		{
			return _ht.begin();
		}
		iterator end()
		{
			return _ht.end();
		}
		V& operator[](const K& key)
		{
			return _ht.Insert(std::make_pair(key, V())).first->second;
		}
		pair<iterator, bool> insert(const pair<K, V>& value)
		{
			return _ht.Insert(value);
		}
	};
}